#include <iostream>
#include <string>
using namespace std;
string a, b;
long long ans;
int main() {
	cin >> a >> b;
	if (b.size() == 1) {
		cout << 1 << endl;
		return 0;
	}
	unsigned j;
	for (unsigned i = 1; i < a.size(); i++) {
		j = b.size() - 2;
		while (a[i] != b[j]) {
			j--;
		}
		if (a[i - 1] == b[j + 1]) {
			ans++;
		}
	}
	cout << (1 << ans) << endl;
	return 0;
}
